package com.example.braden.answergame.common.view;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.braden.answergame.R;

/**
 * Created by braden on 2018/3/28.
 */

public class RuleDialog extends Dialog {
    private static Context mContext;
    private static RuleDialog instance;

    public RuleDialog(@NonNull Context context) {
        super(context);
        mContext = context;
        initView();
    }

    public RuleDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        mContext = context;
        initView();
    }

    public static RuleDialog getInstance(Context context) {
        if (instance == null || !mContext.equals(context)) {
            synchronized (BackDialog.class) {
                if (instance == null || !mContext.equals(context)) {
                    instance = new RuleDialog(context, R.style.dialog);
                }
            }
        }
        mContext = context;
        return instance;
    }

    private void initView() {
        View view1 = LayoutInflater.from(mContext).inflate(R.layout.rule_dialog, null);
        setContentView(view1);
        ImageView ivClose = findViewById(R.id.iv_close);
        TextView tvContent = findViewById(R.id.tv_content);
        ivClose.setOnClickListener(view -> dismiss());


    }

    public void showDialog() {
        show();
    }

    public void dismissDialog() {
        dismiss();
    }
}